package com.ease.platform.auditlog.support;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

import com.ease.model.system.AuditLog;
import com.ease.platform.auditlog.vo.AuditLogObject;

public class AuditLogContext implements Serializable {

	/**
	 *
	 */
	private static final long serialVersionUID = -9124981055625329381L;

	private static final ThreadLocal<AuditLogContext> threadLocal = new ThreadLocal<AuditLogContext>();

	private List<AuditLogObject> auditLogObjects;

	private AuditLog auditLog;

	public static AuditLogContext getAuditLogContext() {
		return threadLocal.get();
	}

	public static void setAuditLogContext(AuditLogContext auditLogContext) {
		threadLocal.set(auditLogContext);
	}

	public static void remove() {
		threadLocal.remove();
	}

	public void addAuditLogObject(AuditLogObject auditLogObject) {
		if (null == auditLogObjects) {
			auditLogObjects = new LinkedList<AuditLogObject>();
		}
		auditLogObjects.add(auditLogObject);
	}

	/**
	 * @return the auditLog
	 */
	public AuditLog getAuditLog() {
		return auditLog;
	}

	/**
	 * @param auditLog
	 *            the auditLog to set
	 */
	public void setAuditLog(AuditLog auditLog) {
		this.auditLog = auditLog;
	}

	/**
	 * @return the auditLogObjects
	 */
	public List<AuditLogObject> getAuditLogObjects() {
		return auditLogObjects;
	}

	/**
	 * @param auditLogObjects
	 *            the auditLogObjects to set
	 */
	public void setAuditLogObjects(List<AuditLogObject> auditLogObjects) {
		this.auditLogObjects = auditLogObjects;
	}
}
